package com.yanzhen.controller;


import com.github.pagehelper.PageInfo;
import com.yanzhen.model.LeaveInfo;
import com.yanzhen.model.Log;
import com.yanzhen.service.LogService;
import com.yanzhen.util.JsonObject;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author 王文龙
 * @since 2023-05-09
 */
@Api(tags = {"日志管理系统"})
@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    private LogService logService;

    /**
     *高级分页查询接口
     */
    @GetMapping("/queryLogList")
    public JsonObject queryLogList(String username,String operation,
                                   @RequestParam(defaultValue="1") int page,
                                   @RequestParam(defaultValue="10") int limit){

        //封装对象
        Log log=new Log();
        log.setUsername(username);
        log.setOperation(operation);

        //创建返回结果集对象
        JsonObject jsonObject=new JsonObject();
        PageInfo<Log> pageInfo = logService.queryLogList(page,limit,log);
        jsonObject.setCode(20000);
        jsonObject.setTotal(pageInfo.getTotal());
        jsonObject.setData(pageInfo.getList());
        return jsonObject;
    }
}

